<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:set var="qury"
	value="&newstype=${newstype }&findtype=${ftype}&findkey=${fkey}" />
<c:set var="burl" value="?cpage=" />


<div id="contents">
	<div id="newslist_main">
		<div id="newslist" class="panel-success">
			<div class="panel-heading">
				<b>뉴스 리스트</b>
			</div>
			<table class="table table-hover">
				<colgroup>
					<col style="width: 10%;" />
					<col style="width: 10%;" />
					<col style="width: 50%;" />
					<col style="width: 20%;" />
				</colgroup>
				<tr class="warning">
					<th style="width: 150px;">뉴스번호</th>
					<th>뉴스타입</th>
					<th>제목</th>
					<th>작성자</th>
					<th>작성일</th>
				</tr>


				<c:forEach var="nw" items="${newslist}">

					<c:if test="${nw.newstype eq 1 }">
						<c:set var="newstype" value="뉴스"></c:set>
					</c:if>
					<c:if test="${nw.newstype eq 2 }">
						<c:set var="newstype" value="인터뷰"></c:set>
					</c:if>
					<c:if test="${nw.newstype eq 3 }">
						<c:set var="newstype" value="리뷰"></c:set>
					</c:if>
					<tr>
						<td>${nw.newsno }</td>
						<td>${newstype}</td>
						<td><a href="news_update.bi?newsno=${nw.newsno}">${nw.newstit}</a></td>
						<td>${nw.writer }</td>
						<td>${nw.wdate.substring(0,10)}</td>
					</tr>
					<c:set var="startbno" value="${startbno-1 }" />
				</c:forEach>
			</table>

		</div>
		<div id="search" class="clearf">
			<p>

				<c:if test="${cpage ne 1}">
					<a href="?${burl}1">처음</a>
				</c:if>
				<c:if test="${cpage ne 1 }"><a href="${burl}${cpage-1}${qury}" title="이전-1"> ◀ </a></c:if>
				<c:if test="${cpage eq 1 }"> ◀ </c:if>
				<c:if test="${cpage ge 11 }"><a href="${burl}${cpage-10}${qury}" title="이전-10"> ◁◁ </a>	</c:if>
				<c:if test="${cpage le 10 }"> ◁◁ </c:if>
				
				<%--페이지 네비게이션 출력 --%>
				<c:forEach var="p" begin="${startnav }" end="${startnav+9 }">
					<c:if test="${p le allpage }">
						<!-- 맨 마지막 페이지 까지만 출력 -->
						<c:if test="${cpage eq p }">
							<span class="cpage">${p}</span>
						</c:if>
						<c:if test="${cpage ne p}">
							<a href="${burl}${p}${qury}">${p}</a>
						</c:if>
					</c:if>
				</c:forEach>

				<c:if test="${cpage ne allpage and cpage+9 lt allpage}"><a href="${burl}${cpage+10}${qury}" title="이전+10"> ▷▷ </a></c:if>
				<c:if test="${cpage+9 gt allpage }"> ▷▷ </c:if>	
				<c:if test="${cpage ne allpage}"><a href="${burl}${cpage+1}${qury}" title="이전+1"> ▶ </a></c:if>

				
				<c:if test="${cpage eq allpage }"> ▶ </c:if>
				<c:if test="${cpage ne allpage }"><a href="${burl}${allpage}" title="마지막페이지로 이동">마지막</a></c:if>
			</p>

			<select name="findtype"><option>선탁하세요</option>
				<option value="newstit">제목</option>
				<option value="newscontents">본문</option>
				<option value="wdate">작성일</option>
			</select> <input type="text" name="findkey" />
			<button type="button" id="findbtn">검색하기</button>

		</div>

	</div>

</div>

<script type="text/javascript">
	var findbtn = document.getElementById("findbtn");
	findbtn.onclick = function() {

		var ftype = document.getElementsByName("findtype")[0].value;
		var fkey = document.getElementsByName("findkey")[0].value;
		var newstype = "${newstype}";
		var url = "";
		var find = "?newstype=" + newstype + "&findtype=" + ftype + "&findkey="
				+ fkey;
		//var find ="?findtype=" + ftype + "&findkey=" + fkey;
		location.href = url + find;

	};
</script>

